#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int n, k;
struct Node {
  ll w;
  int h;
  bool operator<(const Node& o) const {
    if (w != o.w) return w > o.w;
    return h > o.h;
  }
};

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> k;
  priority_queue<Node> pq;
  rep(i, 1, n) {
    ll w;
    cin >> w;
    pq.push(Node{w, 0});
  }
  int c = (n - 1) % (k - 1);
  if (c == 0)
    c = k;
  else
    c++;
  ll sum = 0;
  while (pq.size() > 1) {
    int h = 0;
    ll w = 0;
    rep(i, 1, c) {
      Node t = pq.top();
      pq.pop();
      h = max(t.h, h);
      w += t.w;
    }
    sum += w;
    pq.push(Node{w, h + 1});
    c = k;
  }
  cout << sum << endl << pq.top().h;
  return 0;
}